package vars

import (
	"github.com/sirupsen/logrus"

	"gitee.com/csingo/cHelper"
	"gitee.com/csingo/cLog"
)

var LogConfig = &cLog.LogConf{
	Level:   logrus.Level(cHelper.EnvToInt("LOG_LEVEL", int(cLog.TraceLevel))),
	Drivers: []cLog.LogDriver{cLog.LOG_DRIVER_STDOUT},
	WithFields: map[string]any{
		"app": "gitee.com/csingo/example",
		"env": cHelper.EnvToString("APP_ENV", "local"),
	},
	Excludes: []string{
		cLog.LOG_FIELD_REPORTER,
	},
	Clients: cLog.LogConf_Clients{
		File: cLog.FileHook{
			Path: cHelper.EnvToString("LOG_FILE_PATH", "/dev/stdout"),
			Rotation: cLog.FileHook_Rotation{
				Enable:  cHelper.EnvToBool("LOG_ROTATION_ENABLE", false),
				Type:    cLog.RotationType(cHelper.EnvToString("LOG_ROTATION_TYPE", string(cLog.ROTATION_TYPE_HOUR))),
				MaxFile: int64(cHelper.EnvToInt("LOG_ROTATION_MAX_FILE", 120)),
				MaxSize: int64(cHelper.EnvToInt("LOG_ROTATION_MAX_FILE_SIZE", 1024*1024*1024)),
			},
		},
		Loki: cLog.LokiHook{
			Host:         "",
			Uri:          "",
			QueueMaxSize: 100,
			QueueSpeed:   10,
			Timeout:      10,
		},
		Stdout: cLog.StdoutHook{
			Format:   cLog.LOG_FORMAT_TEXT,
			Colorful: true,
		},
	},
}
